/*
 * Copyright 2009 Vladimir Ritz Bossicard
 *
 * This file is part of OraDoc.
 *
 * OraDoc is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * Version     : $Revision: 20 $
 * Last edit   : $Date: 2009-03-25 12:43:30 +0000 (Wed, 25 Mar 2009) $
 * Last editor : $Author: vbossica $
 */
package org.oradoc.projects.outputters;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.oradoc.Version;
import org.oradoc.outputters.AbstractHtmlOutputter;
import org.oradoc.projects.Project;
import org.oradoc.structures.outputters.TablesHtmlOutputter;
import org.oradoc.structures.outputters.ViewsHtmlOutputter;
import org.oradoc.utils.freemarker.HtmlOutputTemplate;

/**
 *
 * @author Vladimir Ritz Bossicard
 */
public class ProjectHtmlOutputter extends AbstractHtmlOutputter implements ProjectOutputter {

    public void output(final Project project) throws Exception {
        Date current = new Date();

        Map<String, Object> model = new HashMap<String, Object>();
        model.put("project", project);
        model.put("info", new Version());
        model.put("current", new SimpleDateFormat("yyyy.MM.ss HH:mm:ss").format(current));

        new HtmlOutputTemplate(model, this.cfg, "index.html.ftl").process(this.outDir, "index.html");

        model.put("tables", project.getAllTables());
        TablesHtmlOutputter tablesOutputter = new TablesHtmlOutputter();
        tablesOutputter.setConfiguration(this.cfg);
        tablesOutputter.setOutputDir(this.outDir);
        tablesOutputter.output(model);

        model.put("views", project.getAllViews());
        ViewsHtmlOutputter viewsOutputter = new ViewsHtmlOutputter();
        viewsOutputter.setConfiguration(this.cfg);
        viewsOutputter.setOutputDir(this.outDir);
        viewsOutputter.output(model);
    }

}